package com.usian.controller;

import com.usian.pojo.TbContentCategory;
import com.usian.service.ContentCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 韩耀东
 * @date 2021/1/8 8:34
 */
@RestController
@RequestMapping("/contentCategory")
public class ContentCategoryController {

    @Autowired
    private ContentCategoryService contentCategoryService;

    /**
     * @return java.util.List<com.usian.pojo.TbContentCategory>
     * @Author 韩耀东
     * @Description //TODO 根据父节点 ID 查询子节点
     * @Date 2021/1/8 8:46
     * @Param [parentId]
     **/
    @RequestMapping("/selectContentCategoryByParentId")
    public List<TbContentCategory> selectContentCategoryByParentId(Long parentId) {
        return contentCategoryService.selectContentCategoryByParentId(parentId);
    }

    @RequestMapping("/insertContentCategory")
    public Integer insertContentCategory(@RequestBody TbContentCategory tbContentCategory) {
        return contentCategoryService.insertContentCategory(tbContentCategory);
    }

    @RequestMapping("/updateContentCategory")
    public Integer updateContentCategory(Long id, String name) {
        return contentCategoryService.updateContentCategory(id,name);
    }

    @RequestMapping("/deleteContentCategoryById")
    Integer deleteContentCategoryById(Long categoryId) {
        return contentCategoryService.deleteContentCategoryById(categoryId);
    }
}
